class Person(object):
    def __init__(self, hobbys):
        self.hobbys = hobbys

    def __len__(self):
        return len(self.hobbys)

person = Person(['篮球', '足球', '乒乓球'])
"""
没有添加__len__
TypeError: object of type 'Person' has no len()
添加__len__不会报错
"""
print(len(person))

